
package com.shai.wool.admin.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.shai.wool.admin.entity.PostVO;
import com.shai.wool.admin.param.PostParam;
import com.shai.wool.admin.service.AdminService;
import com.shai.wool.common.controller.BaseController;

/**
 * Controller
 *
 * @author 朱国军
 * @since 1.0
 * @version 2015年12月27日 朱国军
 */
@Controller
public class AdminController extends BaseController {

    @Autowired
    private AdminService adminService;

    private final static String POST_LIST_PAGE = "/admin/post_manage";
    
    private static final String STAT_PAGE = "/admin/stat_info";

    @RequestMapping(value = "/admin/post/list")
    public ModelAndView queryList(PostParam postParam) {
        if (postParam.getDiscussType() == null || postParam.getDiscussType() == 0) {
            postParam.setDiscussType(1);
        }
        Map<String, Object> resultMap = new HashMap<String, Object>();
        List<PostVO> dataList = adminService.queryByPage(postParam);
        resultMap.put("dataList", dataList);
        resultMap.put("paramMap", postParam);
        return new ModelAndView(POST_LIST_PAGE, resultMap);
    }
    
    @RequestMapping(value = "/admin/stat/info")
    public ModelAndView queryStatData() {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("statData", adminService.queryStatData());
        return new ModelAndView(STAT_PAGE, resultMap);
    }
}
